package com.platform.qujia.service;



import com.platform.qujia.param.request.AddPayOrderParam;
import com.platform.qujia.param.request.PayOrderRequest;
import com.platform.qujia.pojo.*;
import com.platform.qujia.pojo.dto.ReductionAndCouponDTO;


import java.math.BigDecimal;
import java.time.LocalTime;
import java.util.List;
import java.util.Map;

/**
 * 立减活动Service接口
 *
 * @author qujia
 * @date 2021-11-02
 */
public interface ReductionActivityService
{
    /**
     * 查询立减活动
     *
     * @param activityId 立减活动ID
     * @return 立减活动
     */
    public ReductionActivity selectReductionActivityById(Long activityId);

    /**
     * 查询油站活动介绍
     * @return
     */
    public String selectReductionActivity(Integer stationId);

    /**
     * 查询立减活动列表
     *
     * @param reductionActivity 立减活动
     * @return 立减活动集合
     */
    public List<ReductionActivity> selectReductionActivityList(ReductionActivity reductionActivity);

    /**
     * 新增立减活动
     *
     * @param reductionActivity 立减活动
     * @return 结果
     */
    public int insertReductionActivity(ReductionActivity reductionActivity);


    /**
     * 修改立减活动
     *
     * @param reductionActivity 立减活动
     * @return 结果
     */
    public int updateReductionActivity(ReductionActivity reductionActivity);

    /**
     * 批量删除立减活动
     *
     * @param activityIds 需要删除的立减活动ID
     * @return 结果
     */
    public int deleteReductionActivityByIds(Long[] activityIds);

    /**
     * 删除立减活动信息
     *
     * @param activityId 立减活动ID
     * @return 结果
     */
    public int deleteReductionActivityById(Long activityId);

    /**
     * 查询立减活动的完整信息
     *
     * @param activityId 立减活动规则ID
     * @return 结果
     */
    public Map<String,Object> selectActivityInfoByActivityId(Long activityId);

    public Map<String,Object> selectReductionByPayOrder(AppUserInfo appUserInfos, PayOrder payOrder, String activityUse,
                                                        PayOrderRequest payOrderRequest, Station stationInfos,StaOilGun staOilGun);
    public Map<String,Object> selectReductionByPayOrderCoupon(AppUserInfo appUserInfos, PayOrder payOrder, String activityUse,
                                                              PayOrderRequest payOrderRequest,Station stationInfos, StaOilGun staOilGun) throws Exception;
    public Map<String,Object> selectReductionAndCouponByPayOrder(AppUserInfo appUserInfos, PayOrder payOrder, String activityUse,
                                                                 PayOrderRequest payOrderRequest, Station stationInfos);

    BigDecimal selectVisitorReductionByPayOrder(BigDecimal amt,PayOrder payOrder,AppUserInfo appUserInfo);

    PayOrder calculateCouponAndActivity(PayOrder payOrder);
    /**
     * 校验订单中优惠券是否可用，并且计算优惠金额以及优惠后金额
     *
     * @param appUserInfos
     * @param payOrder
     * @param stationInfos
     * @return 用户优惠券
     */
    public CouponUser checkCoupon(AppUserInfo appUserInfos, PayOrder payOrder, Station stationInfos);

    public CouponUser newCheckCoupon(AppUserInfo appUserInfos, PayOrder payOrder, Station stationInfos);
    
    /**
     * 立减活动查询（pos机使用查询）
     * @param vo
     * @return
     */
    public List<ReductionActivitiesAmountVO> selectReductionActivityStationId(ReductionActivitiesVO vo);
    
    /**
     * 只更新随机立减活动的预算，原因是别的活动方式没有预算
     * @param decimal
     * @param activityId
     * @return
     */
    public int updateReductionActivityBudget(BigDecimal decimal,Integer activityId);

    Map<String,Object> getRCHReductionAmt(AppUserInfo appUserInfos, PayOrder payOrder, PayOrderRequest payOrderRequest, Station stationInfo);

    Map<String,Object> getRCHReductionAmt(String physicalCardNo, BigDecimal amt,Long stationId,Long oilId,String orderLiters);


    public boolean isAmtUpperLimit(ReductionActivity reductionActivity,BigDecimal amt);

    public CouponUser getDiscountMaxCoupon(BigDecimal amt, String receivableAmt, List<CouponUser> couponUsers, String mobilePhone);

    /**
     * 判断时间是否在设置区间内，不判断星期几或几号是否符合
     * @param reductionActivity
     * @param week
     * @param month
     * @param nowTime
     * @return
     */
    boolean checkDayTime(ReductionActivity reductionActivity, int week, int month, LocalTime nowTime);

    Integer getUserOrderId(AppUserInfo appUserInfo);

    public List<ReductionActivity> checkLabelUser(List<ReductionActivity> reductionActivities,String mobilePhone,Long enterpriseId);
    public List<ReductionActivitiesAmountVO> checkLabelUser2(List<ReductionActivitiesAmountVO> reductionActivities,String mobilePhone);
    /**
     * 计算立减优惠，区分有会员没有会员
     * @param orderParam
     * @param payOrder
     * @param station
     * @param staOilGun
     * @param userInfo
     * @return
     */
    ReductionAndCouponDTO calculateReductionDiscount(AddPayOrderParam orderParam, PayOrder payOrder, Station station, StaOilGun staOilGun, AppUserInfo userInfo) throws Exception;

    /**
     * 判断支付方式
     * @param activity
     * @param payType
     * @param dzkCardType
     * @param physicalCardOilType 实体卡油品类型，汽油卡、柴油卡...
     * @param physicalCardType 实体卡类型，定额卡...
     * @return true，符合，false，不符合
     */
    boolean checkActivityPayMethod(ReductionActivity activity,String payType,String dzkCardType,String physicalCardOilType,String physicalCardType);
}
